package la.iok.hzsvn.lewin.movie.mapper;

import la.iok.hzsvn.lewin.movie.entity.PlayRoleBook;
import la.iok.hzsvn.lewin.movie.model.PlayRoleBookVo;
import la.iok.hzsvn.lewin.mybatis.mapper.BaseMapper;
import la.iok.hzsvn.share.annotations.NotNull;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PlayRoleBookMapper extends BaseMapper<PlayRoleBook> {
    @Select("SELECT * FROM `PlayRoleBook` WHERE `playRoleId`=#{playRoleId} AND `chapterId`=#{chapterId}")
    PlayRoleBook select(@NotNull Long playRoleId, @NotNull Long chapterId);

    @Select("SELECT b.*,c.name,c.sequence FROM PlayRoleBook b JOIN BookChapter c ON b.chapterId=c.id WHERE c.movieId=#{movieId} ORDER BY b.playRoleId,c.sequence")
    List<PlayRoleBookVo> movieRoleBooks(Long movieId);
}
